package BC78_筛选法求素数;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        ArrayList<Integer> arr = new ArrayList<>();
        arr.add(2);int cont = 0;

        for (int i = 3; i <= n; i++){
            int j = 2;
            while (j < i){
                if (i % j == 0){
                    cont++;
                    break;
                }
                j++;
            }
            if (i == j){
                arr.add(i);
            }
        }

        for (Integer e : arr){
            System.out.printf(e + " ");
        }
        System.out.println();
        System.out.println(cont);
    }
}
